package modes

import (
	"time"
)

/*登录终端ip*/
type StudentTerm struct {
	Id   int64  `json:"id"`                //  id
	UId  int64  `json:"uid" xorm:"uid"`    //  学员ID
	At   int64  `json:"exam_at" xorm:"at"` //  创建时间
	Type int64  `json:"type" xorm:"type"`  //  终端类型 1、苹果手机2、苹果平板，3、平板 4、安卓
	Info string `json:"info" xorm:"info"`  //  终端id
}

func (this *StudentTerm) TableName() string {
	return "student_term"
}
func (this *StudentTerm) Save() (int64, error) {
	this.At = time.Now().Unix()
	return Db(0).Insert(this)
}

func (this *StudentTerm) Get() (bool, error) {
	return Db(0).Get(this)
}

func (this *StudentTerm) Update(where string, field string) (int64, error) {
	return Db(0).Where(where).Cols(field).Update(this)
}

func (this *StudentTerm) GetTermIdList(uidList []int64) (list []string, err error) {
	err = Db(0).Table(this.TableName()).Select("info").Distinct("info").In("uid", uidList).Find(&list)
	return
}
